package pl.edu.mimuw.mas.editor.widget;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

import pl.edu.mimuw.mas.chart.Chart;

/**
 * Implementacja widgeta do podgladu mapy i edytowanego obszaru.
 */
public class SelectionWidget extends Composite {
	
	private SelectionCanvas canvas;

	public SelectionWidget(Composite arg0, int arg1) {
		super(arg0, arg1);
		
		canvas = new SelectionCanvas(this, SWT.NONE);
		
		canvas.addListener(SWT.Modify, new Listener() {
			@Override
			public void handleEvent(Event e) {
				notifyListeners(SWT.Modify, e);
			}
		});
		
		this.setLayout(new FillLayout());
	}
	
	public void setChart(Chart chart) {
		canvas.setChart(chart);
	}
	
	public void redraw() {
		super.redraw();
		canvas.redraw();
	}
	
}
